﻿<%@ WebHandler Language="C#" Class="delPCenter" %>

using System;
using System.Web;
using System.Web.SessionState;

public class delPCenter : IHttpHandler,IRequiresSessionState {
    
    public void ProcessRequest (HttpContext context) {
        BLL.LostAndFound blllaf = new BLL.LostAndFound();
        if (common.isLoginOrNot())
        {
            int userid = ((MODEL.Users)context.Session["currentUser"]).UId;
            //todo通过querystring传过来的数据有误的时候的处理（错误页）
            if (context.Request.QueryString["id"] != null && context.Request.QueryString["img"] != null)
            {
                int lid = Convert.ToInt32(context.Request.QueryString["id"]);
                string img = context.Request.QueryString["img"].ToString();
                if (blllaf.softDelByLId(lid))
                {
                    //是默认图片则不删除
                    if (img != "noimg.png")
                    {
                        if (common.deleteFile(img))
                        {
                            context.Response.Redirect("PersonCenter.aspx");
                        }
                    }
                    else
                    {
                        context.Response.Redirect("PersonCenter.aspx");
                    }
                }
                else
                {
                   
                }
            }
            
        }
        else
        {
            context.Response.Redirect("index.aspx");
        }
    }
 
    public bool IsReusable {
        get {
            return false;
        }
    }

}